<?php

namespace Plugins\AdminBasic\Models;

use App\Models\Model;
use Carbon\Carbon;
use App\Models\Attributes\CreateSql;


/**
 * Token 版本
 * 
 * @property int    $id          ID
 * @property string $token_id    tokenJTI
 * @property int    $version     当前版本
 * @property Carbon $create_time 创建时间
 * @property Carbon $update_time 更新时间
 * @property int    $delete_time 删除时间
 */
#[CreateSql(<<<SQL
CREATE TABLE `sd_token` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `token_id` char(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'tokenJTI',
  `version` int(11) NOT NULL DEFAULT '0' COMMENT '当前版本：jtiv',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `update_time` datetime NOT NULL COMMENT '更新时间',
  `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`id`),
  KEY `token_id` (`token_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Token 版本'
SQL)]
class BasicToken extends Model
{


    protected array $casts = [
        ...self::DEFAULT_CASTS,
        'id' => 'int',
        'version' => 'int'
    ];

    protected array $fillable = ['token_id', 'version'];

    protected ?string $table = 'basic_token';
}